-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local MCpldValidating = {}

---@class MCpldValidating.ValidatingCpldFlag
---@field ValidatingCpldFlag integer
local TValidatingCpldFlag = {}
TValidatingCpldFlag.__index = TValidatingCpldFlag
TValidatingCpldFlag.group = {}

local function TValidatingCpldFlag_from_obj(obj)
    return setmetatable(obj, TValidatingCpldFlag)
end

function TValidatingCpldFlag.new(ValidatingCpldFlag)
    return TValidatingCpldFlag_from_obj({ValidatingCpldFlag = ValidatingCpldFlag or 0})
end
---@param obj MCpldValidating.ValidatingCpldFlag
function TValidatingCpldFlag:init_from_obj(obj)
    self.ValidatingCpldFlag = obj.ValidatingCpldFlag or 0
end

function TValidatingCpldFlag:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TValidatingCpldFlag.group)
end

TValidatingCpldFlag.from_obj = TValidatingCpldFlag_from_obj

TValidatingCpldFlag.proto_property = {'ValidatingCpldFlag'}

TValidatingCpldFlag.default = {0}

TValidatingCpldFlag.struct = {{name = 'ValidatingCpldFlag', is_array = false, struct = nil}}

function TValidatingCpldFlag:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'ValidatingCpldFlag', self.ValidatingCpldFlag, 'uint8', false, errs, need_convert)

    TValidatingCpldFlag:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TValidatingCpldFlag.proto_property, errs, need_convert)
    return self
end

function TValidatingCpldFlag:unpack(_)
    return self.ValidatingCpldFlag
end

MCpldValidating.ValidatingCpldFlag = TValidatingCpldFlag

---@class MCpldValidating.SystemId
---@field SystemId integer
local TSystemId = {}
TSystemId.__index = TSystemId
TSystemId.group = {}

local function TSystemId_from_obj(obj)
    return setmetatable(obj, TSystemId)
end

function TSystemId.new(SystemId)
    return TSystemId_from_obj({SystemId = SystemId or 1})
end
---@param obj MCpldValidating.SystemId
function TSystemId:init_from_obj(obj)
    self.SystemId = obj.SystemId or 1
end

function TSystemId:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSystemId.group)
end

TSystemId.from_obj = TSystemId_from_obj

TSystemId.proto_property = {'SystemId'}

TSystemId.default = {0}

TSystemId.struct = {{name = 'SystemId', is_array = false, struct = nil}}

function TSystemId:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Required(prefix .. 'SystemId', self.SystemId, 'uint8', false, errs, need_convert)

    TSystemId:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSystemId.proto_property, errs, need_convert)
    return self
end

function TSystemId:unpack(_)
    return self.SystemId
end

MCpldValidating.SystemId = TSystemId

return MCpldValidating
